/*
编写 : Hexh
时间 : 2012-5-25 17:19:10
*/
using System;
using System.Collections;
using System.Text;
using HMIS.FrameWork.DomainBase;
using HMIS.Infrastructure.Core.Authority;
using HMIS.FrameWork;

namespace FsCarInfo.Core.Entity
{
	/// <summary>
	///	the entity of FsIntlVehicleAppl
	/// </summary>
	[Serializable]
	public class FsIntlVehicleAppl : BaseEntity
	{

		#region Public Properties

		/// <summary>
		/// 申请用户ID
		/// </summary>
		public virtual string ApplUserid { get; set; }

		/// <summary>
		/// 申请用户
		/// </summary>
		public virtual HospUser ApplUser { get; set; }

		/// <summary>
		/// 申请时间
		/// </summary>
		public virtual DateTime ApplDate { get; set; }

		/// <summary>
		/// 车辆ID
		/// </summary>
		public virtual string CarId { get; set; }

		/// <summary>
		/// 车辆
		/// </summary>
		public virtual FsIntlVehicle IntlVehicle { get; set; }

		/// <summary>
		/// 司机
		/// </summary>
		public virtual string Driver { get; set; }

		/// <summary>
		/// 用车事由
		/// </summary>
		public virtual string Business { get; set; }

		/// <summary>
		/// 用车类型
		/// </summary>
		public virtual string Type { get; set; }

		/// <summary>
		/// 计划路线
		/// </summary>
		public virtual string PlanPath { get; set; }

		/// <summary>
		/// 出发里程
		/// </summary>
		public virtual decimal? MileageOut { get; set; }

		/// <summary>
		/// 返回里程
		/// </summary>
		public virtual decimal? MileageRet { get; set; }

		/// <summary>
		/// 用车里程
		/// </summary>
		public virtual decimal? Mileage
		{
			get
			{
				if (MileageOut != null && MileageRet != null && MileageOut != 0 && MileageRet != 0)
				{
					return MileageRet - MileageOut;
				}
				else
				{
					return null;
				}
			}
			set
			{
				;
			}
		}

		/// <summary>
		/// 预计出发
		/// </summary>
		public virtual DateTime ExpOutTime { get; set; }

		/// <summary>
		/// 预计返回
		/// </summary>
		public virtual DateTime ExpRetTime { get; set; }

		/// <summary>
		/// 实际出发
		/// </summary>
		public virtual DateTime? ActOutTime { get; set; }

		/// <summary>
		/// 实际返回
		/// </summary>
		public virtual DateTime? ActRetTime { get; set; }

		/// <summary>
		/// 客户姓名
		/// </summary>
		public virtual string TtCustName { get; set; }
		/// <summary>
		/// 联系电话
		/// </summary>
		public virtual string TtCustTel { get; set; }

		/// <summary>
		/// 车牌
		/// </summary>
		public virtual string TtCarNo { get; set; }

		/// <summary>
		/// 拖车结果
		/// </summary>
		public virtual int TtState { get; set; }

		/// <summary>
		/// 原因
		/// </summary>
		public virtual string TtReason { get; set; }

		/// <summary>
		/// 拖车费用
		/// </summary>
		public virtual decimal? TtFee { get; set; }

		/// <summary>
		/// 状态
		/// </summary>
		public virtual FsIntlVehicleApplState State { get; set; }

		/// <summary>
		/// 提醒短信发送时间。默认是创建时间
		/// 用于控制提醒短信的间隔
		/// </summary>
		public virtual DateTime SmsTime { get; set; }

		#endregion

		#region method

		public virtual string ToSmsString()
		{
			string smsStr = String.Format("[用车单]\n申请:{0}\n车辆:{1},\n类型:{2}\n司机:{3}\n出发:{4}\n返回:{5}\n路线:{6}\n事由:{7}",
				this.ApplUser.Name, this.IntlVehicle.CarNo, this.Type, this.Driver, this.ExpOutTime, this.ExpRetTime, this.PlanPath, this.Business);
			return smsStr;
		}

		#endregion
	}

	/// <summary>
	/// 申请状态
	/// </summary>
	public enum FsIntlVehicleApplState
	{
		/// <summary>
		/// 待提交
		/// </summary>
		[EnumDescription("待提交")]
		Editing = 0,

		/// <summary>
		/// 待审批
		/// </summary>
		[EnumDescription("待审批")]
		Appling = 1,

		/// <summary>
		/// 否决
		/// </summary>
		[EnumDescription("否决")]
		Refused = 9,

		/// <summary>
		/// 已审批
		/// </summary>
		[EnumDescription("已审批")]
		Agreed = 2,

		/// <summary>
		/// 已出发
		/// </summary>
		[EnumDescription("已出发")]
		Processing = 3,

		/// <summary>
		/// 已返回
		/// </summary>
		[EnumDescription("已返回")]
		Returned = 4
	}

	/// <summary>
	/// 用车类型
	/// </summary>
	public enum FsIntlVehicleApplType
	{
		/// <summary>
		/// 公车
		/// </summary>
		[EnumDescription("公车")]
		OffiCar = FsIntlVehicleType.OffiCar,

		/// <summary>
		/// 私车公用
		/// </summary>
		[EnumDescription("私车公用")]
		PersCar = FsIntlVehicleType.PersCar,

		/// <summary>
		/// 客户代用
		/// </summary>
		[EnumDescription("客户代用")]
		CustUs = 101
	}
}
